package com.zsrt.java.model.proxy2.ex;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class UserProxy implements InvocationHandler {
	
	private Object obj;

	
	
	
	public UserProxy(Object obj) {
		super();
		this.obj = obj;
	}

	public Object getProxyUser(){
		
		Object o = Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), this);
		
		return o;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("执行代理");
		Object jg = method.invoke(obj, args);
		System.out.println("结束代理");
		return jg;
	}

}
